package com.sysystem.controller;

import java.util.List;

import org.springframework.web.bind.annotation.RestController;

import com.sysystem.enums.BaseRetCode;
import com.sysystem.vo.BaseResponseVO;
import com.sysystem.vo.EmptyRetData;
import com.sysystem.vo.EmptyRetDatas;

@RestController
public class BaseController {

    public BaseResponseVO buildRespone() {
        return new BaseResponseVO(BaseRetCode.CODE_SUCCESS);
    }

    public BaseResponseVO buildRespone(BaseRetCode baseRetCode, Object retData) {
        return new BaseResponseVO(baseRetCode, retData);
    }

    public BaseResponseVO buildRespone(BaseRetCode baseRetCode, List<?> records) {
        return new BaseResponseVO(baseRetCode, records);
    }

    public BaseResponseVO buildRespone(BaseRetCode baseRetCode) {
        return new BaseResponseVO(baseRetCode);
    }

    public BaseResponseVO buildResultDataRespone(Object retData) {
        if (retData == null) {
            retData = EmptyRetData.instance;
        }
        return new BaseResponseVO(BaseRetCode.CODE_SUCCESS, retData);
    }

    public BaseResponseVO buildResultDataRespone(List<Object> retData) {
        if (retData == null) {
            retData = EmptyRetDatas.instance;
        }
        return new BaseResponseVO(BaseRetCode.CODE_SUCCESS, retData);
    }
}
